package dryven.i18n;

import java.text.MessageFormat;

public class MessageFormatTranslator implements Translator {

	private TranslationSource _source;
	
	public MessageFormatTranslator(TranslationSource source) {
		super();
		_source = source;
	}

	@Override
	public String translate(String key, Object... params) {
		String pattern = _source.getTranslationFormatString(key);
		if(pattern==null) {
			return "???"+key+"???";
		}
		String result = MessageFormat.format(pattern, params);
		return result;
	}

}
